package com.ming.mapper;

import com.ming.pojo.LastSevenCount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface CountMapper {
    /**
     * 最近七天进入次数
     * @return
     */

    @Select("SELECT MONTH(enter_time) AS `month`,DAY(enter_time) AS `day`,COUNT(1) AS counts FROM `all_access_record`\n" +
            "WHERE enter_time BETWEEN DATE_SUB(NOW(),INTERVAL 7 DAY) AND NOW()\n" +
            "GROUP BY MONTH(enter_time),DAY(enter_time)")
    List<LastSevenCount> getByEnterTime();

    /**
     * 最近七天离开次数
     * @return
     */
    @Select("SELECT MONTH(leave_time) AS `month`,DAY(leave_time) AS `day`,COUNT(1) AS counts FROM `all_access_record`\n" +
            "WHERE leave_time BETWEEN DATE_SUB(NOW(),INTERVAL 7 DAY) AND NOW()\n" +
            "GROUP BY MONTH(leave_time),DAY(leave_time)")
    List<LastSevenCount> getByLeaveTime();

    /**
     * 获取不同车辆类型出入记录次数
     * @return
     */
    @Select("SELECT COUNT(*)\n" +
            "FROM all_access_record\n" +
            "GROUP BY is_interior\n" +
            "ORDER BY is_interior")
    List<Integer> getTypeCount();



}
